use "data/individual/GPSS Environment.dta", clear


***Survey Variables
gen year=yr
la var year "Period"

//Cohort
gen yr_born=year-age if age!=0&age<99
recode yr_born ///
	(1900/1924=5 "<1924") ///
	(1925/1929=6 "1925-1929") ///
	(1930/1934=7 "1930-1934") ///
	(1935/1939=8 "1935-1939") ///
	(1940/1944=9 "1940-1944") ///
	(1945/1949=10 "1945-1949") ///
	(1950/1954=11 "1950-1954") ///
	(1955/1959=12 "1955-1959") ///
	(1960/1964=13 "1960-1964") ///
	(1965/1969=14 "1965-1969") ///
	(1970/1974=15 "1970-1974") ///
	(1975/1979=16 "1975-1979") ///
	(1980/1984=17 "1980-1984") ///
	(1985/1989=18 "1985-1989") ///
	(1990/1994=19 "1990-1994") ///
	(1995/2010=20 ">=1999"), ///
	gen(cohort)
la var cohort "Age Cohort, 5 yr. intervals"

***Dependent variables
recode envworry_gw ///
	(1 2 = 1 "Great deal/fair amount") ///
	(3 4 = 0 "Only a little/not at all") ///
	(5 6 = .), ///
	gen(cc_worry)
la var cc_worry "Climate Change Worry"

recode gw_when ///
	(1 = 1 "Already happening") ///
	(2 3 4 5 = 0 "Only a little/not at all") ///
	(else = .), ///
	gen(cc_when)
la var cc_when "Climate Change Already Happening"

recode gw_serious ///
	(1 = 1 "Exaggerated") ///
	(2 3 = 0 "Not Already happening") ///
	(else = .), ///
	gen(cc_exagg)
la var cc_exagg "Climate Change Exaggerated"

***Independent Variables
recode partyr ///
	(1=1 "GOP") ///
	(2 = 2 "Independent") ///
	(3 = 3 "Democrat") ///
	(else=.), ///
	gen(partyid3)
la var partyid3 "Party Identification"

recode educ ///
	(1 = 1 "<=HS") ///
	(2 = 2 "Some College") ///
	(3 = 3 "College Deg.") ///
	(4=4 "Grad Deg.") ///
	(else=.), ///
	gen(education)
la var education "Highest Education Degree"

replace age=. if age==0
replace age=89 if age>=89
la var age "Age"


recode gr ///
	(2=1 "Female") ///
	(1=0 "Not female") ///
	(else=.), ///
	gen(female)
la var female "Female"

recode raceban2 ///
	(1=1 "White") ///
	(2=2 "Black") ///
	(3=3 "Hispanic") ///
	(4 7 9 = 4 "Other"), ///
	gen(race)
la var race "Racial/Ethnic Identification"
	

recode cregion ///
	(3=1 "South") ///
	(1 2 4 = 0 "Not south"), ///
	gen(south)
la var south "Southern State"



//Add in older versions
preserve
do "data/individual/older_gallup/recode Gallup_ASCII.do"
restore 

preserve
do "data/individual/older_gallup/recode Gallup_1997_Nov.do"
restore 

append using "data/individual/older_gallup/Gallup_1989_May_recode.dta"
append using "data/individual/older_gallup/Gallup_1990_Apr_recode.dta"
append using "data/individual/older_gallup/Gallup_1991_Apr_recode.dta"
append using "data/individual/older_gallup/Gallup_1997_Nov_recode.dta"
append using "data/individual/older_gallup/Gallup_1999_Apr_recode.dta"

//Label data
gen data=3
la def data 1 "GSS" 2 "Pew" 3 "Gallup"
la val data data

//Keep required
keep ///
	data year yr_born cohort id ///
	cc_worry ///
	cc_when ///
	cc_exagg ///
	partyid3 education ///
	age female race south 

//Save
save "data/individual/Gallup_1989_2021_recode.dta", replace

	
